<html>
<head>
    <title>SystemUiHider.java</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
        .ln { color: rgb(0,0,0); font-weight: normal; font-style: normal; }
        .s0 { color: rgb(0,0,128); font-weight: bold; }
        .s1 { }
        .s2 { color: rgb(128,128,128); font-style: italic; }
        .s3 { color: rgb(128,128,128); font-style: italic; }
        .s4 { color: rgb(128,128,128); font-weight: bold; font-style: italic; }
        .s5 { color: rgb(0,0,255); }
    </style>
</head>
<BODY BGCOLOR="#ffffff">
<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#C0C0C0">
    <TR>
        <TD>
            <CENTER>
                <FONT FACE="Arial, Helvetica" COLOR="#000000">
                    SystemUiHider.java</FONT>
            </center>
        </TD>
    </TR>
</TABLE>
<pre>

<a name="l1"><span class="ln">1    </span></a><span class="s0">package </span><span class="s1">com.ibr.ticketmanagement.app.util; 
<a name="l2"><span class="ln">2    </span></a> 
<a name="l3"><span class="ln">3    </span></a></span><span class="s0">import </span><span
        class="s1">android.app.Activity;
<a name="l4"><span class="ln">4    </span></a></span><span class="s0">import </span><span
        class="s1">android.os.Build;
<a name="l5"><span class="ln">5    </span></a></span><span class="s0">import </span><span
        class="s1">android.view.View;
<a name="l6"><span class="ln">6    </span></a> 
<a name="l7"><span class="ln">7    </span></a></span><span class="s2">/** 
<a name="l8"><span class="ln">8    </span></a> * A utility class that helps with showing and hiding system UI such as the 
<a name="l9"><span class="ln">9    </span></a> * status bar and navigation/system bar. This class uses backward-compatibility 
<a name="l10"><span class="ln">10   </span></a> * techniques described in </span><span class="s3">&lt;a href=</span><span
        class="s2">
<a name="l11"><span class="ln">11   </span></a> * &quot;http://developer.android.com/training/backward-compatible-ui/index.html&quot;&gt; 
<a name="l12"><span class="ln">12   </span></a> * Creating Backward-Compatible UIs</span><span
        class="s3">&lt;/a&gt; </span><span class="s2">to ensure that devices running any
<a name="l13"><span class="ln">13   </span></a> * version of ndroid OS are supported. More specifically, there are separate 
<a name="l14"><span class="ln">14   </span></a> * implementations of this abstract class: for newer devices, 
<a name="l15"><span class="ln">15   </span></a> * {</span><span class="s4">@link </span><span
        class="s2">#getInstance} will return a {</span><span class="s4">@link <a
        href="SystemUiHiderHoneycomb.java.html">SystemUiHiderHoneycomb</a></span><span class="s2">} instance,
<a name="l16"><span class="ln">16   </span></a> * while on older devices {</span><span class="s4">@link </span><span
        class="s2">#getInstance} will return a
<a name="l17"><span class="ln">17   </span></a> * {</span><span class="s4">@link <a
        href="SystemUiHiderBase.java.html">SystemUiHiderBase</a></span><span class="s2">} instance.
<a name="l18"><span class="ln">18   </span></a> * </span><span class="s3">&lt;p&gt;</span><span
        class="s2">
<a name="l19"><span class="ln">19   </span></a> * For more on system bars, see </span><span
        class="s3">&lt;a href=</span><span class="s2">
<a name="l20"><span class="ln">20   </span></a> * &quot;http://developer.android.com/design/get-started/ui-overview.html#system-bars&quot; 
<a name="l21"><span class="ln">21   </span></a> * &gt; System Bars</span><span
        class="s3">&lt;/a&gt;</span><span class="s2">.
<a name="l22"><span class="ln">22   </span></a> *  
<a name="l23"><span class="ln">23   </span></a> * </span><span class="s4">@see </span><span
        class="s2">android.view.View#setSystemUiVisibility(int)
<a name="l24"><span class="ln">24   </span></a> * </span><span class="s4">@see </span><span
        class="s2">android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN
<a name="l25"><span class="ln">25   </span></a> */</span><span class="s1"> 
<a name="l26"><span class="ln">26   </span></a></span><span class="s0">public abstract class </span><span
        class="s1">SystemUiHider {
<a name="l27"><span class="ln">27   </span></a>    </span><span class="s2">/** 
<a name="l28"><span class="ln">28   </span></a>     * When this flag is set, the 
<a name="l29"><span class="ln">29   </span></a>     * {</span><span class="s4">@link </span><span
        class="s2">android.view.WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN}
<a name="l30"><span class="ln">30   </span></a>     * flag will be set on older devices, making the status bar &quot;float&quot; on top 
<a name="l31"><span class="ln">31   </span></a>     * of the activity layout. This is most useful when there are no controls at 
<a name="l32"><span class="ln">32   </span></a>     * the top of the activity layout. 
<a name="l33"><span class="ln">33   </span></a>     * </span><span class="s3">&lt;p&gt;</span><span
        class="s2">
<a name="l34"><span class="ln">34   </span></a>     * This flag isn't used on newer devices because the </span><span
        class="s3">&lt;a</span><span class="s2">
<a name="l35"><span class="ln">35   </span></a>     * href=&quot;http://developer.android.com/design/patterns/actionbar.html&quot;&gt;action 
<a name="l36"><span class="ln">36   </span></a>     * bar</span><span
        class="s3">&lt;/a&gt;</span><span class="s2">, the most important structural element of an Android app, should
<a name="l37"><span class="ln">37   </span></a>     * be visible and not obscured by the system UI. 
<a name="l38"><span class="ln">38   </span></a>     */</span><span class="s1"> 
<a name="l39"><span class="ln">39   </span></a>    </span><span
        class="s0">public static final int </span><span class="s1">FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES = </span><span
        class="s5">0x1</span><span class="s1">;
<a name="l40"><span class="ln">40   </span></a> 
<a name="l41"><span class="ln">41   </span></a>    </span><span class="s2">/** 
<a name="l42"><span class="ln">42   </span></a>     * When this flag is set, {</span><span
        class="s4">@link </span><span class="s2">#show()} and {</span><span class="s4">@link </span><span
        class="s2">#hide()} will toggle
<a name="l43"><span class="ln">43   </span></a>     * the visibility of the status bar. If there is a navigation bar, show and 
<a name="l44"><span class="ln">44   </span></a>     * hide will toggle low profile mode. 
<a name="l45"><span class="ln">45   </span></a>     */</span><span class="s1"> 
<a name="l46"><span class="ln">46   </span></a>    </span><span
        class="s0">public static final int </span><span class="s1">FLAG_FULLSCREEN = </span><span
        class="s5">0x2</span><span class="s1">;
<a name="l47"><span class="ln">47   </span></a> 
<a name="l48"><span class="ln">48   </span></a>    </span><span class="s2">/** 
<a name="l49"><span class="ln">49   </span></a>     * When this flag is set, {</span><span
        class="s4">@link </span><span class="s2">#show()} and {</span><span class="s4">@link </span><span
        class="s2">#hide()} will toggle
<a name="l50"><span class="ln">50   </span></a>     * the visibility of the navigation bar, if it's present on the device and 
<a name="l51"><span class="ln">51   </span></a>     * the device allows hiding it. In cases where the navigation bar is present 
<a name="l52"><span class="ln">52   </span></a>     * but cannot be hidden, show and hide will toggle low profile mode. 
<a name="l53"><span class="ln">53   </span></a>     */</span><span class="s1"> 
<a name="l54"><span class="ln">54   </span></a>    </span><span
        class="s0">public static final int </span><span class="s1">FLAG_HIDE_NAVIGATION = FLAG_FULLSCREEN | </span><span
        class="s5">0x4</span><span class="s1">;
<a name="l55"><span class="ln">55   </span></a> 
<a name="l56"><span class="ln">56   </span></a>    </span><span class="s2">/** 
<a name="l57"><span class="ln">57   </span></a>     * The activity associated with this UI hider object. 
<a name="l58"><span class="ln">58   </span></a>     */</span><span class="s1"> 
<a name="l59"><span class="ln">59   </span></a>    </span><span class="s0">protected </span><span
        class="s1">Activity mActivity;
<a name="l60"><span class="ln">60   </span></a> 
<a name="l61"><span class="ln">61   </span></a>    </span><span class="s2">/** 
<a name="l62"><span class="ln">62   </span></a>     * The view on which {</span><span class="s4">@link </span><span
        class="s2">View#setSystemUiVisibility(int)} will be called.
<a name="l63"><span class="ln">63   </span></a>     */</span><span class="s1"> 
<a name="l64"><span class="ln">64   </span></a>    </span><span class="s0">protected </span><span
        class="s1">View mAnchorView;
<a name="l65"><span class="ln">65   </span></a> 
<a name="l66"><span class="ln">66   </span></a>    </span><span class="s2">/** 
<a name="l67"><span class="ln">67   </span></a>     * The current UI hider flags. 
<a name="l68"><span class="ln">68   </span></a>     *  
<a name="l69"><span class="ln">69   </span></a>     * </span><span class="s4">@see </span><span
        class="s2">#FLAG_FULLSCREEN
<a name="l70"><span class="ln">70   </span></a>     * </span><span class="s4">@see </span><span
        class="s2">#FLAG_HIDE_NAVIGATION
<a name="l71"><span class="ln">71   </span></a>     * </span><span class="s4">@see </span><span
        class="s2">#FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES
<a name="l72"><span class="ln">72   </span></a>     */</span><span class="s1"> 
<a name="l73"><span class="ln">73   </span></a>    </span><span
        class="s0">protected int </span><span class="s1">mFlags;
<a name="l74"><span class="ln">74   </span></a> 
<a name="l75"><span class="ln">75   </span></a>    </span><span class="s2">/** 
<a name="l76"><span class="ln">76   </span></a>     * The current visibility callback. 
<a name="l77"><span class="ln">77   </span></a>     */</span><span class="s1"> 
<a name="l78"><span class="ln">78   </span></a>    </span><span class="s0">protected </span><span
        class="s1">OnVisibilityChangeListener mOnVisibilityChangeListener = sDummyListener;
<a name="l79"><span class="ln">79   </span></a> 
<a name="l80"><span class="ln">80   </span></a>    </span><span class="s2">/** 
<a name="l81"><span
        class="ln">81   </span></a>     * Creates and returns an instance of {</span><span
        class="s4">@link </span><span class="s2">SystemUiHider} that is
<a name="l82"><span class="ln">82   </span></a>     * appropriate for this device. The object will be either a 
<a name="l83"><span class="ln">83   </span></a>     * {</span><span class="s4">@link <a
        href="SystemUiHiderBase.java.html">SystemUiHiderBase</a></span><span
        class="s2">} or {</span><span class="s4">@link <a href="SystemUiHiderHoneycomb.java.html">SystemUiHiderHoneycomb</a></span><span
        class="s2">} depending on
<a name="l84"><span class="ln">84   </span></a>     * the device. 
<a name="l85"><span class="ln">85   </span></a>     *  
<a name="l86"><span class="ln">86   </span></a>     * </span><span class="s4">@param </span><span
        class="s2">activity The activity whose window's system UI should be
<a name="l87"><span class="ln">87   </span></a>     *            controlled by this class. 
<a name="l88"><span class="ln">88   </span></a>     * </span><span class="s4">@param </span><span
        class="s2">anchorView The view on which
<a name="l89"><span class="ln">89   </span></a>     *            {</span><span
        class="s4">@link </span><span class="s2">View#setSystemUiVisibility(int)} will be called.
<a name="l90"><span class="ln">90   </span></a>     * </span><span class="s4">@param </span><span
        class="s2">flags Either 0 or any combination of {</span><span class="s4">@link </span><span
        class="s2">#FLAG_FULLSCREEN},
<a name="l91"><span class="ln">91   </span></a>     *            {</span><span
        class="s4">@link </span><span class="s2">#FLAG_HIDE_NAVIGATION}, and
<a name="l92"><span class="ln">92   </span></a>     *            {</span><span
        class="s4">@link </span><span class="s2">#FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES}.
<a name="l93"><span class="ln">93   </span></a>     */</span><span class="s1"> 
<a name="l94"><span class="ln">94   </span></a>    </span><span
        class="s0">public static </span><span class="s1">SystemUiHider getInstance(Activity activity, View anchorView, </span><span
        class="s0">int </span><span class="s1">flags) {
<a name="l95"><span class="ln">95   </span></a>        </span><span class="s0">if </span><span
        class="s1">(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
<a name="l96"><span class="ln">96   </span></a>            </span><span class="s0">return new <a
        href="SystemUiHiderHoneycomb.java.html">SystemUiHiderHoneycomb</a></span><span class="s1">(activity, anchorView, flags);
<a name="l97"><span class="ln">97   </span></a>        } </span><span class="s0">else </span><span
        class="s1">{
<a name="l98"><span class="ln">98   </span></a>            </span><span class="s0">return new <a
        href="SystemUiHiderBase.java.html">SystemUiHiderBase</a></span><span class="s1">(activity, anchorView, flags);
<a name="l99"><span class="ln">99   </span></a>        } 
<a name="l100"><span class="ln">100  </span></a>    } 
<a name="l101"><span class="ln">101  </span></a> 
<a name="l102"><span class="ln">102  </span></a>    </span><span class="s0">protected </span><span
        class="s1">SystemUiHider(Activity activity, View anchorView, </span><span
        class="s0">int </span><span class="s1">flags) {
<a name="l103"><span class="ln">103  </span></a>        mActivity = activity; 
<a name="l104"><span class="ln">104  </span></a>        mAnchorView = anchorView; 
<a name="l105"><span class="ln">105  </span></a>        mFlags = flags; 
<a name="l106"><span class="ln">106  </span></a>    } 
<a name="l107"><span class="ln">107  </span></a> 
<a name="l108"><span class="ln">108  </span></a>    </span><span class="s2">/** 
<a name="l109"><span class="ln">109  </span></a>     * Sets up the system UI hider. Should be called from 
<a name="l110"><span class="ln">110  </span></a>     * {</span><span class="s4">@link </span><span
        class="s2">Activity#onCreate}.
<a name="l111"><span class="ln">111  </span></a>     */</span><span class="s1"> 
<a name="l112"><span class="ln">112  </span></a>    </span><span
        class="s0">public abstract void </span><span class="s1">setup();
<a name="l113"><span class="ln">113  </span></a> 
<a name="l114"><span class="ln">114  </span></a>    </span><span class="s2">/** 
<a name="l115"><span class="ln">115  </span></a>     * Returns whether or not the system UI is visible. 
<a name="l116"><span class="ln">116  </span></a>     */</span><span class="s1"> 
<a name="l117"><span class="ln">117  </span></a>    </span><span
        class="s0">public abstract boolean </span><span class="s1">isVisible();
<a name="l118"><span class="ln">118  </span></a> 
<a name="l119"><span class="ln">119  </span></a>    </span><span class="s2">/** 
<a name="l120"><span class="ln">120  </span></a>     * Hide the system UI. 
<a name="l121"><span class="ln">121  </span></a>     */</span><span class="s1"> 
<a name="l122"><span class="ln">122  </span></a>    </span><span
        class="s0">public abstract void </span><span class="s1">hide();
<a name="l123"><span class="ln">123  </span></a> 
<a name="l124"><span class="ln">124  </span></a>    </span><span class="s2">/** 
<a name="l125"><span class="ln">125  </span></a>     * Show the system UI. 
<a name="l126"><span class="ln">126  </span></a>     */</span><span class="s1"> 
<a name="l127"><span class="ln">127  </span></a>    </span><span
        class="s0">public abstract void </span><span class="s1">show();
<a name="l128"><span class="ln">128  </span></a> 
<a name="l129"><span class="ln">129  </span></a>    </span><span class="s2">/** 
<a name="l130"><span class="ln">130  </span></a>     * Toggle the visibility of the system UI. 
<a name="l131"><span class="ln">131  </span></a>     */</span><span class="s1"> 
<a name="l132"><span class="ln">132  </span></a>    </span><span class="s0">public void </span><span
        class="s1">toggle() {
<a name="l133"><span class="ln">133  </span></a>        </span><span class="s0">if </span><span
        class="s1">(isVisible()) {
<a name="l134"><span class="ln">134  </span></a>            hide(); 
<a name="l135"><span class="ln">135  </span></a>        } </span><span class="s0">else </span><span
        class="s1">{
<a name="l136"><span class="ln">136  </span></a>            show(); 
<a name="l137"><span class="ln">137  </span></a>        } 
<a name="l138"><span class="ln">138  </span></a>    } 
<a name="l139"><span class="ln">139  </span></a> 
<a name="l140"><span class="ln">140  </span></a>    </span><span class="s2">/** 
<a name="l141"><span class="ln">141  </span></a>     * Registers a callback, to be triggered when the system UI visibility 
<a name="l142"><span class="ln">142  </span></a>     * changes. 
<a name="l143"><span class="ln">143  </span></a>     */</span><span class="s1"> 
<a name="l144"><span class="ln">144  </span></a>    </span><span class="s0">public void </span><span
        class="s1">setOnVisibilityChangeListener(OnVisibilityChangeListener listener) {
<a name="l145"><span class="ln">145  </span></a>        </span><span class="s0">if </span><span
        class="s1">(listener == </span><span class="s0">null</span><span class="s1">) {
<a name="l146"><span class="ln">146  </span></a>            listener = sDummyListener; 
<a name="l147"><span class="ln">147  </span></a>        } 
<a name="l148"><span class="ln">148  </span></a> 
<a name="l149"><span class="ln">149  </span></a>        mOnVisibilityChangeListener = listener; 
<a name="l150"><span class="ln">150  </span></a>    } 
<a name="l151"><span class="ln">151  </span></a> 
<a name="l152"><span class="ln">152  </span></a>    </span><span class="s2">/** 
<a name="l153"><span class="ln">153  </span></a>     * A dummy no-op callback for use when there is no other listener set. 
<a name="l154"><span class="ln">154  </span></a>     */</span><span class="s1"> 
<a name="l155"><span class="ln">155  </span></a>    </span><span
        class="s0">private static </span><span class="s1">OnVisibilityChangeListener sDummyListener = </span><span
        class="s0">new </span><span class="s1">OnVisibilityChangeListener() {
<a name="l156"><span class="ln">156  </span></a>        @Override 
<a name="l157"><span class="ln">157  </span></a>        </span><span
        class="s0">public void </span><span class="s1">onVisibilityChange(</span><span class="s0">boolean </span><span
        class="s1">visible) {
<a name="l158"><span class="ln">158  </span></a>        } 
<a name="l159"><span class="ln">159  </span></a>    }; 
<a name="l160"><span class="ln">160  </span></a> 
<a name="l161"><span class="ln">161  </span></a>    </span><span class="s2">/** 
<a name="l162"><span class="ln">162  </span></a>     * A callback interface used to listen for system UI visibility changes. 
<a name="l163"><span class="ln">163  </span></a>     */</span><span class="s1"> 
<a name="l164"><span class="ln">164  </span></a>    </span><span class="s0">public interface </span><span
        class="s1">OnVisibilityChangeListener {
<a name="l165"><span class="ln">165  </span></a>        </span><span class="s2">/** 
<a name="l166"><span class="ln">166  </span></a>         * Called when the system UI visibility has changed. 
<a name="l167"><span class="ln">167  </span></a>         *  
<a name="l168"><span class="ln">168  </span></a>         * </span><span
        class="s4">@param </span><span class="s2">visible True if the system UI is visible.
<a name="l169"><span class="ln">169  </span></a>         */</span><span class="s1"> 
<a name="l170"><span class="ln">170  </span></a>        </span><span
        class="s0">public void </span><span class="s1">onVisibilityChange(</span><span class="s0">boolean </span><span
        class="s1">visible);
<a name="l171"><span class="ln">171  </span></a>    } 
<a name="l172"><span class="ln">172  </span></a>} 
<a name="l173"><span class="ln">173  </span></a></span></pre>
</body>
</html>